package com.blt.car.me;

import android.view.View;
import android.widget.EditText;

import com.blt.car.R;
import com.blt.car.base.BaseTitleBarActivity;
import com.blt.car.base.ViewHolder;

import blt.app_core.api.base.CoreEvent;
import blt.app_core.api.base.CoreManager;
import blt.app_core.api.login.LoginApi;

/**
 * Created by xgp on 2017/6/26.
 */

public class ModifyNickActivity extends BaseTitleBarActivity {
    public static final int MODIFY_NICKNAME_SUCCESS = 2 << 5;
    private EditText nick;

    @Override
    protected int getLayoutId() {
        return R.layout.activity_modify_nick;
    }

    @Override
    protected void initView(ViewHolder holder) {
        mTitleBar.setTitle("修改昵称");
        nick = holder.get(R.id.modify_nick_et_name);
        holder.get(R.id.modify_nick_et_confirm);
        holder.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                CoreManager.getCore(LoginApi.class).modifyNick(nick.getText().toString());
            }
        }, R.id.modify_nick_et_confirm);
    }


    @CoreEvent(coreClientClass = LoginApi.class)
    public void onModifyNick() {
        toastShort("修改成功");
//        Intent intent = new Intent();
//        intent.putExtra("nickname", nick.getText().toString());
//        setResult(MODIFY_NICKNAME_SUCCESS, intent);
        CoreManager.notifyClients(LoginApi.class, LoginApi.onNickBack, nick.getText().toString());
        finish();
    }

}
